package com.gnerv.battle.boot.plugin.openapi.autoconfigure;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author Gnerv LiGen
 */
@Configuration
@ComponentScan(value = "com.gnerv.battle.boot")
@EnableConfigurationProperties(BattlePluginOpenapiConfigProperties.class)
public class BattlePluginOpenapiAutoConfiguration {

    @Bean
    public OpenAPI openApiDoc() {
        return new OpenAPI()
                .info(new Info()
                        .title("业务管理系统在线接口文档")
                        .version("1.0")
                        .description( "业务管理系统在线接口文档")
                        .termsOfService("http://localhost:8080/")
                        .license(new License().name("Apache 2.0")
                                .url("http://localhost:8080/")));
    }

    @Bean
    public GroupedOpenApi allApi() {
        return GroupedOpenApi.builder()
                .group("all")
                .pathsToMatch("/**")
                .build();
    }


}
